package com.feng.feign;

import com.feng.entity.User;
import com.feng.entity.Order;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@FeignClient(value = "user-service")
public interface UserServiceClient {
    @GetMapping("/user/findAll")
    List<User> findAllUsers();

    @GetMapping("/user/findById/{id}")
    User findUserById(@PathVariable("id") Integer id);

    @PostMapping("/user/save")
    User saveUser(@RequestBody User user);

    @PutMapping("/user/update")
    User updateUser(@RequestBody User user);

    @DeleteMapping("/user/deleteById/{id}")
    void deleteUserById(@PathVariable("id") Integer id);
}

@FeignClient(value = "order-service")
interface OrderServiceClient {
    @GetMapping("/order/findAll")
    List<Order> findAllOrders();

    @GetMapping("/order/findById/{id}")
    Order findOrderById(@PathVariable("id") Long id);

    @GetMapping("/order/findByUserId/{userId}")
    List<Order> findOrdersByUserId(@PathVariable("userId") Long userId);

    @PostMapping("/order/save")
    Order saveOrder(@RequestBody Order order);

    @PutMapping("/order/update")
    Order updateOrder(@RequestBody Order order);

    @DeleteMapping("/order/deleteById/{id}")
    void deleteOrderById(@PathVariable("id") Long id);
}